from ssd1306 import SSD1306_I2C
from machine import I2C, Pin
import OLEDMenu
import time


oled_iic = I2C(scl = Pin(14), sda= Pin(13))
key = Pin(0, Pin.IN, Pin.PULL_UP)
LED = Pin(2, Pin.OUT)
state = 0

oled = SSD1306_I2C(128, 64, oled_iic)
oled.fill(0xff)
text = [['music','print("perform a music")'],['photo','m.initText(subtext)','print("Special click detacted")'],['game','a']]
subtext = [['back','m.initText(text)'],['see photo a','a']]
m = OLEDMenu.menu(oled,0,0,128,64)
m.initText(text)
oled.show()

def handler(KEY):
    global state
    time.sleep_ms(10)
    if KEY.value() == 0:
        state = not state
        LED.value(state)
        m.click()
        
key.irq(handler, Pin.IRQ_FALLING)